package com.future.controller;


import com.future.po.DrivingDriver;
import com.future.po.DrivingStatis;
import com.future.service.DrivingDriverService;
import com.future.service.DrivingStatisService;
import com.future.vo.ChartVo;
import com.future.vo.DrivingDriverVo2;
import com.future.vo.ResponseResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/statistic")
@CrossOrigin
public class StatisticController {

    @Autowired
    private DrivingDriverService drivingDriverService;

    @Autowired
    private DrivingStatisService drivingStatisService;
    @GetMapping
    public ResponseResultVo statisticBehave(@RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate){


        List<DrivingDriverVo2> drivingDriverVoList = drivingDriverService.statisticBehaveByDate(startDate, endDate,null);
        return ResponseResultVo.success(drivingDriverVoList);
    }

    @GetMapping("curUser")
    public ResponseResultVo statisticCurUserBehave(@RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate,@RequestParam Integer id){


        List<DrivingDriverVo2> drivingDriverVoList = drivingDriverService.statisticBehaveByDate(startDate, endDate,id);
        return ResponseResultVo.success(drivingDriverVoList);
    }

    @GetMapping("towWeekBehave")
    public ResponseResultVo towWeekBehave(@RequestParam Integer id){
        ChartVo chartVo = drivingStatisService.statisToWeekBehave(id);
        return ResponseResultVo.success(chartVo);
    }
}
